#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define LEN 20

int main(int argc, char *argv[])
{
	FILE *fp;
	char name[LEN];
	char word[LEN];
	int i = 0;
	
	fprintf(stdout,"please enter the file name:\n");
	scanf("%s", name);
	getchar();
	if((fp = fopen(name, "w+")) == NULL)
	{
		fprintf(stderr, "Can't open the file\n");
		exit(EXIT_FAILURE);
	}
//	printf("start:%p\n", fp);
	if((fgets(word, 20, stdin)) == NULL)
		fputs(word, fp);
//	printf("m:%p\n", fp);	
	while(word[i] != '\0'){
		if(islower(word[i]))
			word[i] = toupper(word[i]);
		i++;
	}
//	rewind(fp);
//	printf("end:%p\n", fp);	
	fputs(word, fp);
	if(fclose(fp) !=0)
		fprintf(stderr, "close file fail");
		
	return 0;
}
